<?php
class stFacebookCouponUser_model extends stmodel_2_1{

    public function __construct($config) {
        parent::__construct ( $config );
        $this->setTableName('st_coupon_users');
        $this->setPrimaryKey('CouponUserID');
    }
    public function get_coupon($id){
        global $wpdb;
         return $wpdb->get_var("SELECT CouponTemplateName FROM  st_coupon_templates WHERE CouponTemplateID = (SELECT CouponTemplateID FROM st_coupons WHERE CouponUserID = $id)");
     }
    public function get_date($id){
        global $wpdb;
        $time = $wpdb->get_var("SELECT CouponGeneratedDateTime FROM st_coupons WHERE CouponUserID = $id");
         $array = explode('-',substr($time,0,11));
         $datetime = $array[2].'.'.$array[1].'.'.$array[0].' '.substr($time,11);
        return $datetime;
    }
}